package ai;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.List;

import model.State;

public class GameStatistics {

	private String player1Info,player2Info;
	private String player1Times,player2Times;
	private int boardRows,boardCols;
	private State gameState;
	private List<Double> time1, time2;
	
	public GameStatistics(String player1Info, String player2Info,int boardRows,int boardCols) {
		super();
		this.player1Info = player1Info;
		this.player2Info = player2Info;
		this.boardRows=boardRows;
		this.boardCols=boardCols;
	}
	
	public int getBoardRows() {
		return boardRows;
	}

	public void setBoardRows(int boardRows) {
		this.boardRows = boardRows;
	}

	public int getBoardCols() {
		return boardCols;
	}

	public void setBoardCols(int boardCols) {
		this.boardCols = boardCols;
	}

	public String getPlayer1Info() {
		return player1Info;
	}

	public void setPlayer1Info(String player1Info) {
		this.player1Info = player1Info;
	}

	public String getPlayer2Info() {
		return player2Info;
	}

	public void setPlayer2Info(String player2Info) {
		this.player2Info = player2Info;
	}

	public String getPlayer1Times() {
		return player1Times;
	}

	public void setPlayer1Times(String player1Times) {
		this.player1Times = player1Times;
	}

	public String getPlayer2Times() {
		return player2Times;
	}

	public void setPlayer2Times(String player2Times) {
		this.player2Times = player2Times;
	}

	public State getGameState() {
		return gameState;
	}

	public void setGameState(State gameState) {
		this.gameState = gameState;
	}
	
	public List<Double> getTime1() {
		return time1;
	}

	public void setTime1(List<Double> time1) {
		this.time1 = time1;
	}

	public List<Double> getTime2() {
		return time2;
	}

	public void setTime2(List<Double> time2) {
		this.time2 = time2;
	}

	public void saveOnFile(String path, String name)
	{
		BufferedWriter writer;
		try {
			writer = new BufferedWriter(new FileWriter(new File(path+name)));
			
			String s = createReport();
			writer.write(s);
			writer.flush();
			writer.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	public String createReport()
	{
		String nl = System.getProperty("line.separator");
		StringBuilder sb = new StringBuilder();
		sb.append("GAME STATS:" + nl);
		sb.append("Rows: " + boardRows + " Cols: " + boardCols + nl);
		sb.append("State: " + gameState + nl+nl);
		sb.append(player1Info + nl);
		sb.append("Moves' duration:" + nl);
		sb.append(player1Times + nl+nl);
		
		sb.append(player2Info + nl);
		sb.append("Moves' duration:" + nl);
		sb.append(player2Times + nl + nl);
		
		return sb.toString();
	}
	
	
	
	
	
}
